package com.xieyingwangluo.yxpart.api;

import com.xieyingwangluo.yxpart.bean.Result;
import com.xieyingwangluo.yxpart.entity.CompanyInfoModel;
import com.xieyingwangluo.yxpart.logic.CompanyInfoLogic;
import com.xieyingwangluo.yxpart.service.CompanyInfoService;
import com.xieyingwangluo.yxpart.utils.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;

@CrossOrigin
@Api(tags = "companyinfo接口")
@Controller
@RequestMapping(value = "/api/v1/companyinfo")
public class CompanyInfoBaseRest extends BaseRest {
    @Autowired
    private CompanyInfoLogic companyInfoLogic;

    //  公司详情：
    //显示：公司信息编号（noid）
    @ApiOperation(value = "显示公司信息", notes = "显示公司信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "公司信息编号id", required = true, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/selO")
    public Result selO(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       @RequestParam("noid") String noid
    ) {
        return companyInfoLogic.selO(noid);
    }

    //显示：公司信息列表显示
    @ApiOperation(value = "公司信息列表显示", notes = "公司信息列表显示", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "公司信息编号UUID", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "公司名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "企业类型", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "审核状态（审核通过0，审核不通过1）", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "city", value = "所在城市", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "operat", value = "经营状态", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "duration", value = "经营期限", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "capital", value = "注册资本", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "industry", value = "行业类型", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "join_time", value = "成立日期", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "address", value = "注册地址", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "regist", value = "登记机关", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "creditcode", value = "统一社会信用代码", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "code", value = "组织机构代码", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "scope", value = "经营范围", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "merchant_id", value = "商户id", required = false, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/selA")
    public Result selA(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       /*@RequestParam("name") String name, @RequestParam("city") String city,
                       @RequestParam("address") String address, @RequestParam("state") int state,
                       @RequestParam("join_time") Date join_time, @RequestParam("creditcode") String creditcode,
                       @RequestParam("merchant_id") String merchant_id*/
                       CompanyInfoModel companyInfoModel

    ) {
        return companyInfoLogic.selA(companyInfoModel);
    }
//    noid,name,type,state,city,operat,duration,capital,industry,join_time,address,regist
//   ,creditcode,code,scope,merchant_id


    //添加公司信息:
    @ApiOperation(value = "添加公司信息", notes = "添加公司信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "公司信息编号UUID", required = false, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "name", value = "公司名称", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "type", value = "企业类型", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "state", value = "审核状态（审核通过0，审核不通过1）", required = false, dataType = "int", paramType = "form"),
            @ApiImplicitParam(name = "city", value = "所在城市", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "operat", value = "经营状态", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "duration", value = "经营期限", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "capital", value = "注册资本", required = true, dataType = "int", paramType = "form"),
            @ApiImplicitParam(name = "industry", value = "行业类型", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "join_time", value = "成立日期", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "address", value = "注册地址", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "regist", value = "登记机关", required = true, dataType = "int", paramType = "form"),
            @ApiImplicitParam(name = "creditcode", value = "统一社会信用代码", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "code", value = "组织机构代码", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "scope", value = "经营范围", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "merchant_id", value = "商户id", required = true, dataType = "String", paramType = "form")
    })
    @ResponseBody
    @PostMapping(value = "/add")
    public Result add(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       /*@RequestParam("name") String name, @RequestParam("city") String city,
                       @RequestParam("address") String address, @RequestParam("state") int state,
                       @RequestParam("join_time") Date join_time, @RequestParam("creditcode") String creditcode,
                       @RequestParam("merchant_id") String merchant_id*/
                      CompanyInfoModel companyInfoModel,String time,HttpSession session

    ) {
        return companyInfoLogic.add(companyInfoModel,session,time);
    }

}
